//
//  TTTaobaoHeaderView.m
//  Adorable_Things
//
//  Created by lanou on 16/1/15.
//  Copyright © 2016年 Banana Inc. All rights reserved.
//

#import "TTTaobaoHeaderView.h"

@implementation TTTaobaoHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.backButton.frame = CGRectMake(10, 10, 25, 25);
        [self.backButton setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:(UIControlStateNormal)];
        [self addSubview:self.backButton];
        
        self.favorButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.favorButton.frame = CGRectMake(kWidth - 40, 15, 20, 20);
        [self addSubview:self.favorButton];
        
        self.seg = [[UISegmentedControl alloc]initWithItems:@[@"萌文", @"评论"]];
        _seg.frame = CGRectMake(kWidth / 3, 10, kWidth / 3, 30);
        _seg.selectedSegmentIndex = 0;
        _seg.backgroundColor = [UIColor whiteColor];
        // 设置未选中颜色
        NSDictionary * unselectedTextAttr = @{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor grayColor]};
        [_seg setTitleTextAttributes:unselectedTextAttr forState:UIControlStateNormal];
        
        self.mengwenLabel = [[UILabel alloc] initWithFrame:CGRectMake(_seg.left + 10, _seg.bottom, _seg.width / 4, 2)];
        self.mengwenLabel.backgroundColor = [UIColor redColor];
        self.mengwenLabel.tag = 201;
        [self addSubview:self.mengwenLabel];
        
        self.commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.seg.right - _seg.width / 3 - 5, _seg.bottom, _seg.width / 4, 2)];
        self.commentLabel.backgroundColor = [UIColor whiteColor];
        self.commentLabel.tag = 202;
        [self addSubview:self.commentLabel];
        
        // 设置选中颜色
        NSDictionary *selectedTextAttr = @{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor grayColor]};
        [_seg setTitleTextAttributes:selectedTextAttr forState:UIControlStateSelected];
        _seg.tintColor = [UIColor whiteColor];
        [self addSubview:_seg];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
